package controllers

import (
	"gitee.com/tsingeye/FreeEhome/models"
)


/**
 * @apiDefine fileUpload 文件接口
 */
type FileUploadController struct {
	AuthController
}

/**
 * @api {get} /api/v1/file/list 文件路径列表
 * @apiVersion 1.0.0
 * @apiGroup fileUpload
 * @apiName FileList
 * @apiSuccessExample  {json} Response-Example
 * {
 *   "errCode": 200,
 *   "errMsg": "OK",
 *   "fileList": [
 *      "D:/GoWork/src/rcs/EHome/image/560796072_1/20210408/xxx.jpeg"
 *    ]
 * }
 */
func (this *FileUploadController) FileList() {
	this.Data["json"] = models.FileList()
	this.ServeJSON()
}

/**
 * @api {get} /api/v1/file/download 文件下载
 * @apiVersion 1.0.0
 * @apiGroup fileUpload
 * @apiName FileDownload
 * @apiParam {String} fileName 包含绝对路径的文件名
 */
func (this *FileUploadController) FileDownload() {
	fileName := this.GetString("fileName")
	if fileName != "" {
		this.Ctx.Output.Download(fileName)
	}
}
